<template>
  <view class="container">
    <z-paging ref="paging" v-model="list" @query="getlist">
      <template #top>
        <view class="header">
          <text class="header-title">训练计划</text>
        </view>
      </template>

      <view class="plan-list">
        <view
          class="plan-card"
          v-for="(item, index) in list"
          :key="index"
          @click="handleTargetDetail(item)"
        >
          <view class="plan-name">{{item.planName}}</view>
          <view class="card-indicator">
            <u-icon name="arrow-right" color="#999" size="28"></u-icon>
          </view>
        </view>
      </view>
    </z-paging>

    <!-- <view class="add-button" @click="addPlan">
      <text class="button-text">添加计划</text>
    </view> -->
  </view>
</template>

<script>
import { planIns } from "../../api/fit";
export default {
  data() {
    return {
      list: [],
      id: "",
    };
  },
  onLoad(e) {
    this.id = e.id;
  },
  methods: {
    async getlist(pageNo, pageNum = 10) {
      let data = {
        page: pageNo,
        size: pageNum,
        planName: "",
        customerId: this.id,
      };
      const res = await planIns(data);
      this.$refs.paging.complete(res.data.list);
    },
    addPlan() {
      uni.navigateTo({
        url: `/pages/customer/addplan?id=${this.id}`,
      });
    },
    handleTargetDetail(val) {
      uni.navigateTo({
        url: `/pages/kecheng/index?id=${val.id}&customerId=${this.id}`,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  min-height: 100vh;
  background-color: #f7f8fa;
  padding-bottom: 120rpx;
}

.header {
  background: #000;
  color: #fff;

  padding: 40rpx 30rpx;
  box-shadow: 0 2rpx 20rpx rgba(0, 0, 0, 0.03);
  position: sticky;
  top: 0;
  z-index: 10;

  &-title {
    font-size: 50rpx;
    font-weight: 700;
    color: #fff;
    text-align: center;
    display: block;
    letter-spacing: 2rpx;
  }
}

.plan-list {
  padding: 30rpx;
}

.plan-card {
  background: #fff;
  border-radius: 20rpx;
  margin-bottom: 24rpx;
  padding: 40rpx 30rpx;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
  transition: all 0.3s ease;
  
  &:active {
    transform: scale(0.98);
    background: #fafafa;
  }
}

.plan-name {
  font-size: 32rpx;
  font-weight: 600;
  color: #333;
  flex: 1;
}

.card-indicator {
  margin-left: 20rpx;
  opacity: 0.6;
}

.add-button {
  position: fixed;
  bottom: 50rpx;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  background: linear-gradient(135deg, #4a90e2 0%, #2c5282 100%);
  height: 96rpx;
  border-radius: 48rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8rpx 24rpx rgba(74, 144, 226, 0.3);
  transition: all 0.3s ease;

  &:active {
    transform: translateX(-50%) scale(0.98);
    box-shadow: 0 4rpx 12rpx rgba(74, 144, 226, 0.2);
  }

  .button-text {
    color: #fff;
    font-size: 32rpx;
    font-weight: 600;
    letter-spacing: 4rpx;
  }
}

::-webkit-scrollbar {
  width: 0;
  background: transparent;
}
</style>
